#出租车计费
def calculate_fare(distance, waiting_time):
    # 起步费和起步里程
    base_fare = 13
    base_distance = 3
    base_unit_price = 2.3
    surcharge_rate = 1.5  # 超过15公里后的加价比例
    surcharge_distance = 15  # 超过这个里程后加价

    # 计算行驶费用
    if distance <= base_distance:
        fare = base_fare
    elif distance <= surcharge_distance:
        fare = base_fare + (distance - base_distance) * base_unit_price
    else:
        normal_part_fare = (surcharge_distance - base_distance) * base_unit_price
        surcharge_part_fare = (distance - surcharge_distance) * base_unit_price * surcharge_rate
        fare = base_fare + normal_part_fare + surcharge_part_fare
    
    # 计算等待费用
    waiting_fare = waiting_time
    
    # 总费用
    total_fare = fare + waiting_fare
    
    # 取整
    total_fare = int(total_fare)
    
    return total_fare

# 输入乘车里程与等待时间
input_data = input()
distance, waiting_time = map(int, input_data.split(','))

# 计算车费
fare = calculate_fare(distance, waiting_time)

# 输出车费
print(fare)
